<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .clock {
            width: 600px;
            height: 600px;
            border: 1px solid red;
            border-radius: 50%;
            margin: 0 auto;
            position: relative;
        }

        .second {
            width: 2px;
            height: 280px;
            background: red;
            position: absolute;
            left: 50%;
            transform: rotate(0deg);
            transform-origin: center bottom;
            margin-top: 20px;

        }

        .minute{
            width: 4px;
            height: 240px;
            background: blue;
            position: absolute;
            left: 50%;
            transform: rotate(0deg);
            transform-origin: center bottom;
            margin-top: 60px;
        }
        .hour{
            width: 5px;
            height: 200px;
            background: skyblue;
            position: absolute;
            left: 50%;
            transform: rotate(0deg);
            transform-origin: center bottom;
            margin-top: 100px;
        }
    </style>
</head>

<body>
    <div class="clock">
        <div class="second" id="sId"></div>
        <div class="minute"></div>
        <div class="hour"></div>
    </div>
    <script>
        // 设置 dom元素的样式 ： 1.获取元素 2.style属性设置 
        var secondEle = document.getElementsByClassName("second")[0];
        // var sele = document.getElementById("sId");
        var minuteEle = document.getElementsByClassName("minute")[0];
        // console.log(minuteEle);
        // console.log([...minuteEle])
        var hourEle = document.getElementsByClassName("hour")[0];

        // console.log(secondEle,sele)
        // secondEle.style.backgroundColor = "blue";
        function fn() {
            var time = new Date();
            // 获取毫秒数
            var m = time.getMilliseconds();
            // 获取秒
            var second = time.getSeconds()+m/1000;
            var deg = 360 / (60 / second);
            // console.log(second,deg);
            secondEle.style.transform = `rotate(${deg}deg)`;
            
            // 获取分针；
            var minute = time.getMinutes()+second/60;
            var deg2 = 360 / (60/minute);
            minuteEle.style.transform =  `rotate(${deg2}deg)`;


            // 设置时针
            var hour = time.getHours()+minute/60;
            var deg3 = 360/(12/hour);
            hourEle.style.transform = `rotate(${deg3}deg)`;
        }
        fn();
        setInterval(function () {
            fn();
        }, 1);



    </script>
</body>

</html>